<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>用户注册</title>
    <style>
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-color: #f5f7fa;
            margin: 0;
            padding: 0;
            color: #333;
        }

        .container {
            max-width: 500px;
            margin: 3rem auto;
            padding: 2rem;
        }

        h1 {
            color: #2c3e50;
            margin-bottom: 2rem;
            font-weight: 600;
            text-align: center;
        }

        .register-container {
            background: white;
            border-radius: 12px;
            padding: 2.5rem;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
        }

        .form-group {
            margin-bottom: 1.5rem;
            text-align: left;
        }

        label {
            display: block;
            margin-bottom: 0.5rem;
            font-weight: 500;
            color: #334155;
        }

        input[type="text"],
        input[type="password"],
        input[type="email"] {
            width: 100%;
            padding: 0.8rem 1rem;
            border: 1px solid #e2e8f0;
            border-radius: 8px;
            font-size: 1rem;
            transition: all 0.3s;
            box-sizing: border-box;
        }

        input[type="text"]:focus,
        input[type="password"]:focus,
        input[type="email"]:focus {
            outline: none;
            border-color: #3b82f6;
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
        }

        button[type="submit"] {
            width: 100%;
            background-color: #3b82f6;
            color: white;
            border: none;
            padding: 0.8rem;
            border-radius: 8px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.3s;
            font-size: 1rem;
            margin-top: 1rem;
        }

        button[type="submit"]:hover {
            background-color: #2563eb;
            transform: translateY(-2px);
        }

        .nav-links {
            display: flex;
            justify-content: center;
            gap: 1.5rem;
            margin-top: 1.5rem;
        }

        .nav-links a {
            color: #3b82f6;
            text-decoration: none;
            font-weight: 500;
            transition: all 0.2s;
        }

        .nav-links a:hover {
            color: #2563eb;
            text-decoration: underline;
        }

        .error-message {
            color: #ef4444;
            margin-bottom: 1rem;
            text-align: center;
            font-size: 0.9rem;
        }

        .form-hint {
            font-size: 0.8rem;
            color: #64748b;
            margin-top: 0.3rem;
        }
    </style>
</head>
<body>
<div class="container">
    <h1>创建新账户</h1>
    <div class="register-container">
        <!-- 错误消息显示 -->
        <div th:if="${error}" class="error-message" th:text="${error}"></div>

        <form th:action="@{/register}" method="post">
            <div class="form-group">
                <label for="username">用户名</label>
                <input type="text" id="username" name="username"
                       placeholder="4-20个字符" required minlength="4" maxlength="20"/>
                <div class="form-hint">用户名长度在4-20个字符之间</div>
            </div>

            <div class="form-group">
                <label for="password">密码</label>
                <input type="password" id="password" name="password"
                       placeholder="至少6个字符" required minlength="6"/>
                <div class="form-hint">密码长度至少6个字符</div>
            </div>

            <div class="form-group">
                <label for="email">电子邮箱</label>
                <input type="email" id="email" name="email"
                       placeholder="example@domain.com" required/>
                <div class="form-hint">请输入有效的电子邮箱地址</div>
            </div>

            <button type="submit">注册账户</button>
        </form>
    </div>
    <div class="nav-links">
        <a th:href="@{/login}">已有账号？立即登录</a>
        <a th:href="@{/}" style="color: #64748b;">返回首页</a>
    </div>
</div>
</body>
</html>